var a = require("../../utils/config.js");

Page({
    data: {
        userId: "",
        newPassword: "",
        againNewPassword: ""
    },
    onLoad: function(a) {
        this.setData({
            userId: a.userId
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getNewPassword: function(a) {
        this.setData({
            newPassword: a.detail.value
        });
    },
    getAgainNewPassword: function(a) {
        this.setData({
            againNewPassword: a.detail.value
        });
    },
    apply: function() {
        var t = this;
        t.data.newPassword ? t.data.againNewPassword ? t.data.againNewPassword == t.data.newPassword ? (wx.showLoading({
            mask: !0
        }), wx.request({
            url: a.urlList.API_USER_UPDATE_PASSWORD,
            data: {
                userId: t.data.userId,
                newPassword: t.data.newPassword
            },
            method: "POST",
            header: {
                contentType: "application/json"
            },
            success: function(a) {
                wx.hideLoading(), 200 == a.data.status ? (wx.navigateBack({
                    delta: 2
                }), wx.showToast({
                    title: "密码修改成功"
                })) : wx.showToast({
                    title: a.data.message
                });
            }
        })) : wx.showToast({
            title: "两次密码输入不一致",
            icon: "none"
        }) : wx.showToast({
            title: "请输入确认密码",
            icon: "none"
        }) : wx.showToast({
            title: "请设置密码",
            icon: "none"
        });
    }
});